<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.lmpop.trade.tb_commpara.Tb_commparaInfo"%>
<%@ page import="com.lmpop.trade.ti_teamorder.Ti_teamorderInfo"%>
<%@page import="com.lmpop.trade.ti_user.Ti_userInfo"%>
<%
	String order_no = "";
	if (request.getParameter("order_no") != null) {
		order_no = request.getParameter("order_no");
	}
	Ti_teamorderInfo ti_orderinfoInfo = new Ti_teamorderInfo();
	List list = ti_orderinfoInfo.getListByPk(order_no);
	Hashtable map = new Hashtable();
	String user_id = "",title = "",seller="",contact="",cust_id="",vmoney="", order_state = "",name="", num = "", price = "0", ship_price = "0", total_price = "", in_date = "", info_id = "", peisong_no = "", peisong_company = "";
	if (list != null && list.size() > 0){
		map = (Hashtable) list.get(0);
		if (map.get("order_no") != null)
		order_no = map.get("order_no").toString();
		if (map.get("user_id") != null)
			user_id = map.get("user_id").toString();
		if (map.get("title") != null)
			title = map.get("title").toString();
		if (title.length() > 100)
			title = title.substring(0, 100);
		if (map.get("seller") != null)
			seller = map.get("seller").toString();
		if (map.get("contact") != null){
			contact = map.get("contact").toString();
       		
		}
		if (map.get("num") != null)
			num = map.get("num").toString();
		if (map.get("price") != null)
			price = map.get("price").toString();
		if (map.get("ship_price") != null)
			ship_price = map.get("ship_price").toString();
		if (map.get("total_price") != null)
			total_price = map.get("total_price").toString();
		if (map.get("vmoney") != null)
			vmoney = map.get("vmoney").toString();
		if (map.get("order_state") != null)
			order_state = map.get("order_state").toString();
		if (map.get("in_date") != null)
			in_date = map.get("in_date").toString();
		if (in_date.length() > 19)
			in_date = in_date.substring(0, 10);
		if (map.get("info_id") != null)
			info_id = map.get("info_id").toString();
		if (map.get("peisong_no") != null)
			peisong_no = map.get("peisong_no").toString();
		if (map.get("peisong_company") != null)
			peisong_company = map.get("peisong_company").toString();
		if(map.get("name")!=null) name = map.get("name").toString();
		if(map.get("cust_id")!=null) cust_id = map.get("cust_id").toString();	
	}


	

	Tb_commparaInfo tb_commparaInfo = new Tb_commparaInfo();
	
	Ti_userInfo userInfo=new Ti_userInfo();
	list=userInfo.getListByPk(user_id);
	String user_name="",cellphone="",phone="";
	if(list!=null&&list.size()>0){
		map=(Hashtable)list.get(0);
		if(map.get("user_name")!=null)
			user_name=map.get("user_name").toString();
		if(map.get("cellphone")!=null)
			cellphone=map.get("cellphone").toString();
		if(map.get("phone")!=null)
			phone=map.get("phone").toString();
		
	}
	
%>

<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
<div id="order_div">

	<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-bottom: 3px solid #eddfea; padding-left: 15px;" class="tablelist2">
		<tr bgcolor="#fcf8fb">
			<td height="100" valign="top">


				<table width="100%" border="0" cellpadding="0" cellspacing="1">

					<tr class="deal">
						<td colspan="4" height="38">
							&nbsp;&nbsp;
							<img src="/program/admin/images/infotip.gif" border="0">
							
							<span style="font-size: 14px; font-weight: bold;">基本信息</span>
						</td>
					</tr>

					<tr>
						<td height="38" class="art_col" align="center" width="20%">
							订单号:
						</td>
						<td width="25%"><%=order_no%></td>

						<td height="38" class="art_col" width="12%" align="center">
							订单状态:
						</td>
						<td width="60%">

							<table>
								<tr>
									<td width="50%" align="center">
										<%=tb_commparaInfo.getSelectedValue("31", order_state)%>
									</td>
								</tr>
							</table>

						</td>
					</tr>



					<tr  class="deal">
						<td height="28" class="art_col" align="center" width="20%">
							配送单:
						</td>
						<td width="18%">
							<%=peisong_no%></td>

						<td height="28" class="art_col" width="12%" align="center">
							配送公司:
						</td>
						<td width="60%">

							<!--<table>
								<tr>
									<td width="50%" align="center">
										<%=peisong_company%>
									</td>
								</tr>
							</table> -->

						</td>

					</tr>

					<tr>
						<td colspan="4" height="18">
							&nbsp;&nbsp;
							<img src="/program/admin/images/infotip.gif" border="0">
							
							<span style="font-size: 14px; font-weight: bold;">商品及费用信息</span>
						</td>
					</tr>

					<tr >
						<td colspan="4">

							<table width='100%' border="0" cellspacing="1" cellpadding="0">
								<%
									String team_path = "/data/8diantuan/teambuy/";
									String teambuyurl = "";
									teambuyurl = team_path + in_date + "/" + info_id + ".html";
								%>

							<tr>
									<td height="18" class="art_col" align="center" width="20%">
										商家信息:
									</td>
									<td width="100%" height="50">
									<%
											if(!"".equals(contact)){
											
												String[] contactStr = contact.split(",");
												for (int j = 0; j < contactStr.length; j++) {
													String shop_name = "", shop_addr = "", shop_phone = "", shop_web = "";
													String[] son_con = contactStr[j].split("[|]");
													if (son_con.length > 0)
														shop_name = son_con[0];
													if (son_con.length > 1)
														shop_addr = son_con[1];
													if (son_con.length > 2)
														shop_phone = son_con[2];
													if (son_con.length > 3)
														shop_web = son_con[3];
													out.print("<p>店名："+shop_name+"</p><p>地址："+shop_addr+"</p><p>电话号码："+shop_phone+"</p><p>网址："+shop_web+"</p>");
												}
											}
										%>
									</td>
								</tr>

								<tr>
									<td height="18" class="art_col" align="center" width="20%">
										商品信息:
									</td>
									<td width="100%" height="50">
										<a href="<%=teambuyurl%>" target="_blank"><font
											class="goods_name"><%=title%></font>
										</a>
									</td>
								</tr>

								<tr>
									<td height="18" class="art_col" align="center" width="20%">
										单价:
									</td>
									<td width="18">
										￥<%=price%></td>
								</tr>
								<tr>
									<td height="18" class="art_col" align="center" width="20%">
										数量:
									</td>
									<td width="18"><%=num%></td>
								</tr>
								<tr>
									<td height="18" class="art_col" align="center" width="20%">
										虚拟币支付:
									</td>
									<td width="18">
										￥<%=vmoney%></td>
								</tr>
								<tr>
									<td height="18" class="art_col" align="center" width="20%">
										现金支付:
									</td>
									<td width="18">
										￥<%=total_price%></td>
								</tr>
							
								<tr>
									<td width='10%' align='center'>
										费用总计:
									</td>
									<td>
										<span style="color: #666666;">￥<%=Float.parseFloat(total_price)+Integer.parseInt(vmoney)%></span>
									</td>
								</tr>

							</table>

						</td>
					</tr>

				</table>
			</td>
		</tr>
	</table>
</div>
	<form action="/program/member/teamorder/sendEmail.jsp" name="sendEmail"
		method="post" style="display: none">
		<input type="hidden" name="subject" id="subject" value="taonongcun.lmpop.com" />
		<table width="100%" border="0" cellpadding="0" cellspacing="1">
			<!--
			<tr>
				<td height="50">
					标题：
				</td>
				<td height="50">
					<input type="hidden" name="subject" id="subject" value="taonongcun.lmpop.com" />
				</td>
			</tr>
			-->
			<tr>
				<td height="50">
					内容：
				</td>
				<td height="50">
					<textarea name="content" id="content" rows="3" cols="70">您好，我是<%=name %>,我购买的<%=title %>,订单号是：<%=order_no%>请快点为我发货。
               		</textarea>
				</td>
			</tr>
			<input type="hidden" name="user_id" id="user_id"
				value="<%=user_id%>" />
			<input type="hidden" name="cust_id" id="cust_id"
				value="<%=cust_id%>" />
		</table>
	</form>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td height="50" align="center">
				<input type="button" class="button2" name="tradeprint" value="打 印"
					onclick="printPage()" />
					
					<input type="button" class="button2" name="tradeprint" value="提醒发货"
					onclick="showTip();" />
			
			</td>
		</tr>
	</table>


<script type="text/javascript">
	
	function printPage(){
		if(document.sendEmail.style.display=="block"){
			document.sendEmail.style.display="none";
		}
		window.print();
	}
	
	function showTip(){
		if(document.sendEmail.style.display=="none"){
			document.sendEmail.style.display="block";
			return false;
		}
		if(document.sendEmail.subject.value==""){
			alert("邮件标题不能为空");
			document.sendEmail.subject.focus();
			return false;
		}
		if(document.sendEmail.content.value==""){
			alert("邮件内容不能为空");
			document.sendEmail.content.focus();
			return false;
		}
		var subject=document.sendEmail.subject.value;
		var content=document.sendEmail.content.value;
		var user_id=document.sendEmail.user_id.value;
		var cust_id=document.sendEmail.cust_id.value;
		alert("邮件已经发出");
		jQuery.ajax( {
            type : "POST",
            url : "/program/member/teamorder/sendEmail.jsp",
            data : "subject="+encodeURI(encodeURI(subject))+"&content="+content+"&user_id="+user_id+"&cust_id="+cust_id,
            success : function(msg) {
            	//alert(msg);
            }
        });
		//document.sendEmail.submit();
	}
  </script>